<%@ page import="java.io.* , java.util.*, java.sql.*, com.myapp.struts.dao.*,com.myapp.struts.actionform.*,com.myapp.struts.beans.*"%>
<html>
    <!-- DW6 -->
    <head>
        <!-- Copyright 2005 Macromedia, Inc. All rights reserved. -->
        <title>Item Master</title>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
        <link href="../../../../css/cms.css" rel="stylesheet" type="text/css"> 
        <title>CreateJv</title>
        <script language="javascript">
            var k=0,amt1=0;
            function tabEvent(eve, ccount)
            {
                var count = document.getElementById("optionCount").value;
                var keynum;
                if(window.event) // IE
                    keynum = eve.keyCode;
                else if(eve.which) // Netscape/Firefox/Opera
                    keynum = eve.which;
                if(keynum == 9 && ccount == count){
                    count = parseInt(count) + 1;
                    document.getElementById("optionCount").value = count;
                    var appendStr='<br /><select name="achead" id="achead'+count+'"></select><input type="text" name ="debit" id="debit'+count+'"><input type="text" name ="credit" id="credit'+count+'"><input type="text" name="narration" onkeyDown="tabEvent(event,'+count+');">';
                    document.getElementById('rrows').innerHTML = document.getElementById('rrows').innerHTML + appendStr;
                    var eleIds = "achead"+count;
                    fillOptions(eleIds);
                }
            }

            function fillOptions(eleId){
                var elemnt = document.getElementById(eleId);
                var actualEle = document.getElementById('achead');
                for(i=0;i<actualEle.length;i++){
                    addOption(elemnt,actualEle[i].text,actualEle[i].value);
                }
            }

            function addOption(selectbox,text,value )
            {
                var optn = document.createElement("OPTION");
                optn.text = text;
                optn.value = value;
                selectbox.options.add(optn);
            }

        </script>
        <script type="text/javascript">

            var monthtext=[1,2,3,4,5,6,7,8,9,10,11,12];

            function populatedropdown(dayfield, monthfield, yearfield){
                var today=new Date()
                var dayfield=document.getElementById(dayfield)
                var monthfield=document.getElementById(monthfield)
                var yearfield=document.getElementById(yearfield)
                for (var i=0; i<31; i++)
                    dayfield.options[i]=new Option(i, i+1)
                dayfield.options[today.getDate()]=new Option(today.getDate(), today.getDate(), true, true) //select today's day
                for (var m=0; m<12; m++)
                    monthfield.options[m]=new Option(monthtext[m], monthtext[m])
                monthfield.options[today.getMonth()]=new Option(monthtext[today.getMonth()], monthtext[today.getMonth()], true, true) //select today's month
                var thisyear=today.getFullYear()
                for (var y=0; y<20; y++){
                    yearfield.options[y]=new Option(thisyear, thisyear)
                    thisyear+=1
                }
                yearfield.options[0]=new Option(today.getFullYear(), today.getFullYear(), true, true) //select today's year
            }

        </script>
    </head>

    <body>
        <table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
            <tr>
                <td width="907"><br><br><br><br><br><br><br><br><br><br>
                    <form id="form1" name="form1" method="post" action="../../../../JvInsert">
                        <div align="center">
                            <table border="0" cellspacing="0" cellpadding="0" style="border-right: #000000 1px solid;
                                   border-top: #000000 1px solid; border-left: #000000 1px solid;  border-bottom: #000000 1px solid; font-size: 9pt; color: #000000; font-family: Arial;">
                                <tr>
                                    <th height="33" colspan="5">Journal Voucher</th>
                                </tr>

                                <tr>
                                    <td>Journal Voucher No </td>
                                    <td width="140"><input name="jvno" type="text" class="tabledata" size="20" /></td>
                                    <td width="149">Date </td>
                                    <td colspan="2">
                                        <select id="daydropdown" name="daydropdown">
                                            <option></option>
                                        </select>
                                        -
                                        <select id="monthdropdown" name="monthdropdown">
                                            <option></option>
                                        </select>
                                        -
                                        <select id="yeardropdown" name="yeardropdown">
                                            <option></option>
                                        </select>

                                        <script type="text/javascript">

                                            //populatedropdown(id_of_day_select, id_of_month_select, id_of_year_select)
                                            window.onload=function(){
                                                populatedropdown("daydropdown", "monthdropdown", "yeardropdown")
                                            }
                                        </script> </td>
                                </tr>
                                <tr>
                                    <td  >Account</td>
                                    <td  >Debit</td>
                                    <td  >Cretdit</td>
                                    <td colspan="2"  >Narration</td>
                                </tr>
                                <tr>
                                    <td colspan="5" class="columnname"><div id = "rrows">
                                            <input type="hidden" name="optionCount" id="optionCount" value="0"/>
                                            <%
            AcheadDao ad = new AcheadDao();
            ArrayList gpl = ad.list();
            if (gpl != null) {
                Iterator itg = gpl.iterator();
                                            %>
                                            <select name="achead" class="tabledata" id="achead">
                                                <option>select account head</option>
                                                <%
                                                while (itg.hasNext()) {
                                                    AccountHeadFormBean ab = (AccountHeadFormBean) itg.next();%>
                                                <%String ahd = ab.getAccountHeadName();
                                                %>
                                                <option value="<%=ahd%>"><%=ahd%></option>
                                                <%}
            }%>
                                            </select><input name="debit" type="text" class="tabledata" id="debit"/><input name="credit" type="text" class="tabledata" id="credit"/><input name="narration" type="text" class="tabledata" id="narration" onKeyDown="javascript:tabEvent(event, 0);"/>
                                        </div></td>
                                </tr>
                                <tr>
                                    <td colspan="5" align="center" ><input name="Submit" type="submit" class="tabledata" value="Submit" /></td>
                                </tr>
                            </table>
                        </div>
                    </form>
                    <p align="left" >&nbsp;</p>
                    <p>&nbsp;</p>
                    <p>&nbsp;</p>
                    <p>&nbsp;</p>
                    <p>&nbsp;</p>
                    <p>&nbsp;</p>
                    <p>&nbsp;</p>
                    <p>&nbsp;</p>
                    <p>&nbsp;</p>
                    <p>&nbsp;</p></td></tr>
        </table>
    </body>
</html>
